<template>
    <div>
        <!-- 顶部区域 -->
      <div id="slider" class="mui-slider">
        <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
         <div class="mui-scroll">
            <a :class="['mui-control-item',item.id == 0?'mui-active':'']" v-for="item in cates"  :key="item.id"
                data-wid="tab-top-subpage-1.html" @tap="getImagesByCateId(item.id)">
                {{ item.title }}
            </a>
         </div>
        </div>
    </div>
   <!-- 图片列表区域 -->
     <ul class="photolist">
        <router-link v-for="item in list" :key="item.id" :to="'/home/photoinfo/'+item.id" tag="li">
          <img v-lazy="item.img_url">
          <div class="info">
                <h1 class="info-title">现代简约 明亮的外表卧室卧室背景墙、吊顶黄色</h1>
                <div class="info-zhaiyao">
                    不要简朴不要素雅洋气卧室我做主，高低床榻榻米式靓丽卧室装扮，现代油画壁画帆布画卧室餐厅仟象映画，现代中式卧室装修图欣赏，温馨浪漫，而且很时尚的卧室设计，欧式卧室飘窗装修效果图。
                </div>
          </div>
        </router-link>
      </ul>
</div>
</template>

<script>
import mui from '../../lib/mui/js/mui.min.js'

export default {
    data(){
        return {
            cates:[],   //图片列表分类集合
            list:[]    //图片列表集合
        }
    },
    // 页面初始化加载dom完毕之后，在把滚动条进行初始化
    mounted(){
        mui('.mui-scroll-wrapper').scroll({
            deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
        })
    },
    created(){
      this.getImgCategory(),
    //   初始化页面时 ，页面默认显示的是全部的图片列表
      this.getImagesByCateId(0)
    },
    methods:{
        getImgCategory(){
            this.$http.get("api/getimgcategory").then(
                result =>{
                    if(result.body.status == 0){
                        var allCate = {title:"全部",id:0}
                        this.cates = result.body.message
                        this.cates.unshift(allCate)
                    }
                    else{
                        Toast("获取分类失败")
                    }
                }
            )
        },
        //根据图片分类id获取图片列表
        getImagesByCateId(cateId){
             this.$http.get("api/getimages/"+cateId).then(
                 result =>{
                     if(result.body.status ==0){
                         this.list = result.body.message
                     }
                     else{
                        Toast("图片加载失败...")
                     }
                 }
             )
        }
    }
}
</script>

<style lang="scss" scoped> 
.photolist{
    margin:0;
    padding:10px;
    list-style: none;
    padding-bottom:0;
}
.photolist li {
    background-color: #ccc;
    text-align: center;
    margin-bottom: 10px;
    box-shadow:0 0 9px #999;
    position: relative;
}
.photolist li img{
    width: 100%;
    vertical-align: middle;
}
.photolist li img[lazy=loading] 
 {
  width: 40px;
  height: 300px;
  margin: auto;
}

.photolist li .info{
   color:white;
   text-align: left;
   position: absolute;
   bottom: 0;
   background-color:rgba(0,0,0, 0.3);
   max-height: 84px;
}

.photolist li .info-title{
   font-size: 14px;
}

.photolist li .info-zhaiyao{
    font-size: 13px;
}
</style>